package fragments.discover;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.wenxin.administrator.zhufengfm.Constants;
import com.wenxin.administrator.zhufengfm.R;

import java.util.List;
import java.util.Objects;

import fragments.BaseFragment;
import tasks.DiscoverCategoryTask;
import tasks.TaskCallBack;
import tasks.TaskResult;


public class DiscoverCategoryFragment extends BaseFragment implements TaskCallBack {

    public DiscoverCategoryFragment() {
    }

    public String getFragmentTitle() {
        return "分类";
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        DiscoverCategoryTask task = new DiscoverCategoryTask(this);
        task.execute();

    }

    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
       View view=inflater.inflate(R.layout.fragment_discover_category, container, false);
        return view;
    }

    @Override
    public void onTaskFinished(TaskResult result) {
        if(result!=null) {
            int action=result.action;
            if(action== Constants.TASK_ACTION_DISCOVER_CATEGORIES) {
                //todo 结果从发现-分类 任务中返回的
                if(result.resultCode==Constants.TASK_RESULT_OK){
                    //todo 加载成功
                    Object data=result.data;
                    if(data!=null&&data instanceof  List){
                        List list= (List) data;
                        Log.d("Tag",list.size()+"集合大小===========================================");
                    }
                }else{
                    //todo 加载失败
                }
            }
        }
    }
}
